
cluster_level = cluster_level %>% filter(dist < 15000)

plot_soil = loess_plot(x = cluster_level$forcing, y = cluster_level$soil_quality, W = cluster_level$opium_legal, ylab = "Soil Quality (0-3)")
plot_temp = loess_plot(x = cluster_level$forcing, y = cluster_level$temp, W = cluster_level$opium_legal, ylab = "Temperature (C)")
plot_prec = loess_plot(x = cluster_level$forcing, y = cluster_level$prec, W = cluster_level$opium_legal, ylab = "Precipatation (mm)")
plot_rugged = loess_plot(x = cluster_level$forcing, y = cluster_level$rugged, W = cluster_level$opium_legal, ylab = "Ruggedness")


ggsave(plot = plot_soil, "./_4_outputs/figures/appendix_2a_balance_plot.pdf", height = 3, width = 4)
ggsave(plot = plot_temp, "./_4_outputs/figures/appendix_2b_balance_plot.pdf", height = 3, width = 4)
ggsave(plot = plot_prec, "./_4_outputs/figures/appendix_2c_balance_plot.pdf", height = 3, width = 4)
ggsave(plot = plot_rugged, "./_4_outputs/figures/appendix_2d_balance_plot.pdf", height = 3, width = 4)